package com.gxuwz.medical.domain;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.gxuwz.medical.database.DbUtil;

public class UserDAO {
	
	public static List<User> selectUser() {
        List<User> userList = new ArrayList<>();
        Connection conn=null;
        DbUtil dbUtil=new com.gxuwz.medical.database.DbUtil();
		try {
			conn = dbUtil.getConn();
		
        String sql = "select * from t_user";
     
            PreparedStatement pst = conn.prepareStatement(sql);
            ResultSet rs= pst.executeQuery();
            while (rs.next()) {
                User user = new User();
                user.setUserid(rs.getString("userid"));
                user.setPwd(rs.getString("pwd"));
                user.setFullName(rs.getString("fallName"));
            
                userList.add(user);
            }
            rs.close();
            pst.close();
            System.out.println(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return userList;
    }
	}